package com.tarena.charging.cost.controller;

import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.param.ChargingProcessParam;
import cn.tedu.charging.common.pojo.vo.ChargingProcessVO;
import com.tarena.charging.cost.service.CostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api(tags="计价服务")
public class CostController {
    @Autowired
    private CostService costService;

    @PostMapping("/cost/calculate")
    @ApiOperation("计算价格接口")
    public JsonResult<ChargingProcessVO> calcCost(@RequestBody ChargingProcessParam param){
        log.info("计算价格入参:{}",param);
        ChargingProcessVO cost=costService.calcCost(param);
        log.info("计算价格入参:{},出参:{}",param,cost);
        return JsonResult.ok(cost);
    }
}
